<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组件语法糖注册放方式</title>
  </head>
  <body>
    <div id="app">
      <cpn1></cpn1>
      <cpn2></cpn2>
    </div>

    <script src="../vue.js"></script>
    <script>
      //1.全局组件注册的语法糖
      //1.创建组件构造器
      //const cpnC1 = Vue.extend();
      //2.注册组件
      Vue.component("cpn1", {
        template: `
                <div>
                    <h2>你好鸭</h2>
                    <h3>我不好鸭</h3>
                    <p>垃圾一枚</p>
                </div>
            `,
      });

      //2.注册局部组件的语法糖
      const app = new Vue({
        el: "#app",
        data: {
          messahe: "hello",
        },
        components: {
          cpn2: {
            template: `
                <div>
                    <h2>你好鸭2</h2>
                    <h3>我不好鸭</h3>
                    <p>渣渣一个</p>
                </div>
                `,
          },
        },
      });
    </script>
  </body>
</html>
